#!/bin/bash
# 获取系统是centos6还是7等 centos桌面安装解析 桌面解析 桌面版解析
sys_byte=$(rpm -qi centos-release | grep Version | tr -c -d [:digit:])

echo "*******************************************************************************"
echo "安装wget"
echo "*******************************************************************************"
yum install wget -y
echo "*******************************************************************************"
echo "安装wget完成"
echo "*******************************************************************************"

echo "*******************************************************************************"
echo "备份原先的yum命名为CentOS-Base.repo.日期"
echo "*******************************************************************************"
cd /etc/yum.repos.d/
cp /etc/yum.repos.d/CentOS-Base.repo  /etc/yum.repos.d/CentOS-Base.repo.$(date -d "today" +"%Y%m%d_%H%M%S")

echo "*******************************************************************************"
echo "配置yum源为163源"
echo "*******************************************************************************"
# 获取163repo并命名为CentOS-Base.repo
wget http://mirrors.163.com/.help/CentOS$sys_byte-Base-163.repo &&  rm -f CentOS-Base.repo && mv CentOS$sys_byte-Base-163.repo CentOS-Base.repo
echo "*******************************************************************************"
echo "配置yum源为163源成功，可查看cat /etc/yum.repos.d/CentOS-Base.repo"
echo "*******************************************************************************"

yum install yum-plugin-fastestmirror -y
echo "*******************************************************************************"
echo " 配置epel源"
echo "*******************************************************************************"
yum install -y epel-release
echo "*******************************************************************************"
echo " 配置epel源成功"
echo "*******************************************************************************"

echo "*******************************************************************************"
echo " 安装GNOME Desktop 桌面解析 桌面版解析  安装centos桌面解析"
echo "*******************************************************************************"
yum -y groups install "GNOME Desktop"
echo "*******************************************************************************"
echo " 安装GNOME Desktop成功，输入startx可以启动桌面"
echo "*******************************************************************************"
